<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>FileUpload</title>
		<script type="text/javascript" language="javascript">
			window.onload = function() {
				document.getElementById("form").onsubmit = function() {
					var regex = /^\S+$/;
					var form = document.getElementById("form");
					var iderrormsg = document.getElementById("iderrormsg");
					var file1 = form.filename1.value;
					var file2 = form.filename2.value;
					var describe = form.describe.value;
					if (!regex.test(file1)) {
						iderrormsg.textContent = "file1?";
						return false;
					}
					if (!regex.test(file2)) {
						iderrormsg.textContent = "file2?";
						return false;
					}
					if (!regex.test(describe)) {
						iderrormsg.textContent = "describe?";
						return false;
					}
					return true;
				};
			};
		</script>
	</head>
	<body>
		<jsp:include page="/jspdemo/header.jsp" />
		<br>
		<h1>文件上传</h1>
		<br>${msg }
		<br>
		<br>第一个文件：${requestScope.filename1 }
		<br>第二个文件：${requestScope.filename2 }
		<br>文件描述：${requestScope.describe }
		<br>
		<br>
		<form id="form" action="/test/fileOperateServlet?fileoperate=upload" method="post" enctype="multipart/form-data">
			<table border="1" cellspacing="0">
				<tr>
					<td>file1:</td>
					<td><input type="file" name="filename1">
					</td>
				</tr>
				<tr>
					<td>file2:</td>
					<td><input type="file" name="filename2">
					</td>
				</tr>
				<tr>
					<td>describe:</td>
					<td><input type="text" name="describe">
					</td>
				</tr>
				<tr>
					<td><input type="reset" value="重置">
					</td>
					<td><input type="submit" value="上传">
					</td>
				</tr>
			</table>
		</form>
		<label id="iderrormsg" style="color: red"></label>
	</body>
</html>